// 将16进制转rgb
export const decimalConversion = (str: string): string => {

    let reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/

    // 把颜色值变成小写
    let color = str.toLowerCase()
    if (reg.test(color)) {
        if (color.length === 4) {
            let colorNew = "#";
            for (let i = 1; i < 4; i += 1) {
                colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1))
            }
            color = colorNew
        }
        let colorChange = []
        for (let i = 1; i < 7; i += 2) {
            colorChange.push(parseInt("0x" + color.slice(i, i + 2)));
        }
        return "rgba(" + colorChange.join(",") + ", .2)"
    } else {
        return color
    }
}